package com.chat.common.vo;

import lombok.Data;

@Data
public class R<T> {
    private int code;
    private String msg;
    private T data;

    public R() {

    }

    public R(int code, String msg) {
        this.code=code;
        this.msg=msg;
    }

    public R(int code, String msg, T data) {
        this.code=code;
        this.msg=msg;
        this.data=data;
    }

    public static <T> R<T> succeed() {
        return new R<T>(200, "成功");
    }

    public static <T> R<T> succeed(String msg) {
        return new R<T>(200, msg);
    }

    public static <T> R<T> succeed(T data) {
        return new R<T>(200, "成功", data);
    }

    public static <T> R<T> succeed(String msg, T data) {
        return new R<T>(200, msg, data);
    }

    public static <T> R<T> failed() {
        return new R<T>(500, "失败");
    }

    public static <T> R<T> failed(T data) {
        return new R<T>(500, "失败", data);
    }

    public static <T> R<T> failed(String msg, T data) {
        return new R<T>(500, msg, data);
    }

    public static <T> R<T> failed(String msg) {
        return new R<T>(500, msg);
    }

    public static <T> R<T> failed(int code, String msg) {
        return new R<T>(code, msg);
    }

    public static <T> R<T> failed(int code, String msg, T data) {
        return new R<T>(code, msg, data);
    }
}
